package com.xing.morethread.job;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 同步用户信息
 */
public class SyncUserJob extends QuartzJobBean {

    /**
     * 先把整合定时任务写啦，之后再看完档，浏览一遍
     *
     * @param jobExecutionContext
     * @throws JobExecutionException
     */

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        //获取 jobDetail传递的参数
        String userName = (String) jobExecutionContext.getJobDetail().getJobDataMap().get("userName");

        //获取当前时间
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        //打印信息
        System.out.println("用户名称：" + userName);
        System.out.println("当前时间：" + simpleDateFormat.format(date));

    }
}
